package com.wbt.spring.e01.config;


import com.wbt.common.beans.Developer;
import com.wbt.common.beans.Parent;
import com.wbt.common.beans.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@ComponentScan("com.wbt.spring.e01.**")
@Configuration
public class AppConfig {

    @Bean(name = "user1")
    User userOne(){
        User user = new User();
        user.setId("1");
        user.setUserName("李四");
        user.setAge(23);
        user.setWork("架构师A");
        return user;
    }

    @Bean(name = "user2")
    User userTow(){
        User user = new User();
        user.setId("2");
        user.setUserName("小明");
        user.setAge(39);
        user.setWork("COE架构师");
        return user;
    }

    @Bean(name = "user3")
    User userThree(){
        User user = new User();
        user.setId("3");
        user.setUserName("小米");
        user.setAge(33);
        user.setWork("JAVA工程师");
        return user;
    }

    @Bean(name = "developer")
    User developer(){
        Developer user = new Developer();
        user.setId("4");
        user.setUserName("米哈");
        user.setAge(22);
        user.setWork("Test工程师");
        user.setDec("开发者");
        return user;
    }

    @Bean(name = "parent")
    Parent parent(){
        Parent parent = new Parent();
        parent.setId("1");
        parent.setUserName("佛");
        parent.setAge(45);
        parent.setWork("总监");
        List<User> userList = new ArrayList<>();
        userList.add(userOne());
        userList.add(userTow());
        userList.add(userThree());
        parent.setUserList(userList);
        return parent;
    }

    @Bean(name = "parent2")
    Parent parent2(User user1,User user2){
        Parent parent = new Parent();
        parent.setId("2");
        parent.setUserName("哈总");
        parent.setAge(55);
        parent.setWork("CEO");
        List<User> userList = new ArrayList<>();
        userList.add(user1);
        userList.add(user2);
        parent.setUserList(userList);
        return parent;
    }
}
